/******************************************************************
*******************************************************************
**	Engine 
**	Tuesday, October 2, 2012
**	By Tong Lor
*******************************************************************
**  UPDATE: 
**  Wednesday, November 26, 2012
**  Direct Input
******************************************************************/


#include "StuffForMain.h"



int WINAPI WinMain(HINSTANCE hInstance,
				   HINSTANCE hPrevInstance,
				   LPSTR lpCmdLine,
				   int nCmdShow)
{
	ScreenInfo si; // Retreive screen info from Stuff For Main

	HWND hWnd;
	WNDCLASSEX wc;

	ZeroMemory(&wc, sizeof(WNDCLASSEX));

	wc.cbSize = sizeof(WNDCLASSEX);
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = WindowProc;
	wc.hInstance = hInstance;
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
	wc.lpszClassName = TEXT("WindowClass");

	RegisterClassEx(&wc);

	hWnd = CreateWindowEx(NULL, 
						  TEXT("WindowClass"),
						  si.Name_Of_Frame,
						  WS_OVERLAPPEDWINDOW,
						  si.ScreenStartPosX, si.ScreenStartPosY,						// Start position of window
						  si.ScreenWidth, si.ScreenHeight,			// Size of window
						  NULL,
						  NULL,
						  hInstance,
						  NULL);

	ShowWindow(hWnd, nCmdShow);

	MainInit(hWnd, hInstance);

	MSG msg;

	while(TRUE)
	{
		while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		if(msg.message == WM_QUIT)
			break;
		MainUpdate();
		MainRender();
	}


	MainRelease();

	return msg.wParam;
}


